﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Apa.Control;
using Apa.Data;

namespace Apa.Forms
{
    public partial class frmCrearUsuarios : System.Web.UI.Page
    {
        protected void Page_Load(object sender, System.EventArgs e)
        {
            tbl.BorderStyle = BorderStyle.Inset;
            tbl.BorderWidth = Unit.Pixel(1);
        }

        protected void cmdCreate_Click(object sender, System.EventArgs e)
        {
            tbl.Controls.Clear();

            int rows = Int32.Parse(txtRows.Text);
            int cols = Int32.Parse(txtCols.Text);

            Controladora control = new Controladora();
        //    List<Historial> hist = control.universidades().OrderByDescending(x=> x.actulizacionesIES).ToList();

        //    int j=0;
        //    TableRow rowNew = new TableRow();
        //    tbl.Controls.Add(rowNew);

        //    foreach (Historial historial in hist)
        //    {
               

        //        if (j < cols)
        //        //for (int j = 0; j < cols; j++)
        //        {
        //            TableCell cellNew = new TableCell();
        //            Label lblNew = new Label();
        //            lblNew.Text = "(" + historial.numSolicitud + ")<br />";// "(" + i.ToString() + "," + j.ToString() + ")<br />";


        //            Label imgNew = new Label();
        //            if(historial.actulizacionesIES=="POR RENOVAR" || historial.actulizacionesIES==null ){

        //                imgNew.Text = ("<div class=\"round\">" + "" + "</div>");
        //            }

        //            if (historial.actulizacionesIES == "NO")
        //            {

        //                imgNew.Text = ("<div class=\"roundNoRenovado\">" +"" + "</div>");
        //            }

        //            if (historial.actulizacionesIES == "SI")
        //            {

        //                imgNew.Text = ("<div class=\"roundRenovado\">" + "" + "</div>");
        //            }
                    

        //            cellNew.Controls.Add(lblNew);
        //            cellNew.Controls.Add(imgNew);

        //            if (chkBorder.Checked == true)
        //            {
        //                cellNew.BorderStyle = BorderStyle.Inset;
        //                cellNew.BorderWidth = Unit.Pixel(1);
        //            }

        //            rowNew.Controls.Add(cellNew);

        //            j++;
        //        }
        //        else
        //        {
        //            rowNew = new TableRow();
        //            tbl.Controls.Add(rowNew);
        //            j = 0;
        //        }


        //    }

        //    ////for (int i = 0; i < rows; i++)
        //    ////{
        //    ////    TableRow rowNew = new TableRow();
        //    ////    tbl.Controls.Add(rowNew);
        //    ////    for (int j = 0; j < cols; j++)
        //    ////    {
        //    ////        TableCell cellNew = new TableCell();
        //    ////        Label lblNew = new Label();
        //    ////        lblNew.Text = "(" + i.ToString() + "," + j.ToString() + ")<br />";



        //    ////        //System.Web.UI.WebControls.Image imgNew = new System.Web.UI.WebControls.Image();
        //    ////        //imgNew.ImageUrl = "cellpic.png";

        //    ////        Label imgNew = new Label();
        //    ////        imgNew.Text = ("<div class=\"round\">" + lblNew.Text + "</div>");

        //    ////        cellNew.Controls.Add(lblNew);
        //    ////        cellNew.Controls.Add(imgNew);

        //    ////        if (chkBorder.Checked == true)
        //    ////        {
        //    ////            cellNew.BorderStyle = BorderStyle.Inset;
        //    ////            cellNew.BorderWidth = Unit.Pixel(1);
        //    ////        }

        //    ////        rowNew.Controls.Add(cellNew);
        //    ////    }
        //    ////}
        //}

        //protected void Button2_Click(object sender, EventArgs e)
        //{
           
        //    // esto se borra es simplemente una simulación para la renovación
        //    System.Threading.Thread.Sleep(2000);

        //    byte[] bytes = new byte[100];
        //    Random rnd1 = new Random();
        //    int valor=rnd1.Next();


        //    string cedula = tbCedula.Text;
        //    string numSolicitud = tbNumSolicitud.Text;

        //    string fila=tbFila.Text;
        //    string columna = tbColumna.Text;

                       
        //    bool renovar = (valor) % 2 == 0 ? true : false;

        //    //va hasta aquui el proceso de renovar


        //    if(renovar){
            
        //        ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "script", "calcular("+fila+","+columna+",'SI');", true);
            
        //    }else
        //    {
             
        //        ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "script", "calcular(" + fila + "," + columna + ",'NO');", true);

        //    }
        //    if (tbColumna.Text=="17")
        //    {
        //    tbFila.Text = int.Parse(tbFila.Text)+1+"";
        //    tbColumna.Text = "0";
        //    }else{

        //        tbColumna.Text = int.Parse(tbColumna.Text) + 1 + "";
              
        //    }
          //  Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "alert('No hay papeleria disponible');", true);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "script", "renovacionAutomatica()", true);

        }
    }
}